import {Component, EventEmitter,ViewChild, Input, OnInit, Output} from '@angular/core';
import { InitService } from '../../public/serve/init/init.service';
import { template_attribute } from '../product.data';
import { RemoveTableService } from '../../public/serve/remove-table/remove-table.service';
import { Service } from '../../server/server';
import { CudTableService } from '../../public/serve/cud-table/cud-table.service';
import { TemplateAttributeTableComponent } from './template-attribute-table/template-attribute-table.component';
declare var $:any;


@Component({
  selector: 'app-product-task-template-attribute',
  templateUrl: './product-task-template-attribute.component.html',
  styleUrls: ['./product-task-template-attribute.component.css']
})
export class ProductTaskTemplateAttributeComponent implements OnInit {

  @ViewChild("table") table : TemplateAttributeTableComponent;

  @Input() status: any  = '';
  @Input() searchData: any;
  right: any = {
    "templateAttribute": {},
  };

  constructor( 
    public initService: InitService,
    public removeTableService: RemoveTableService,
    public request: CudTableService,
    public server: Service
  ){
    this.right = $.extend(this.right, server.getRight());
  }

  isActive = this.server.isActive;
  ngOnInit() {
    this.server.eventEmit.subscribe((value: any)=>{
      this.isActive = value;
    });
  }

 /**
   * 分页
   * @param pagination 
   */ 
  _pagination(pagination: Array<any>) {
    template_attribute.pagination.pageNo = pagination[0].pageNumber;
    template_attribute.pagination.pageSize   = pagination[0].pageSize;
    template_attribute.pagination.naturalNum = (template_attribute.pagination.pageNo - 1) * template_attribute.pagination.pageSize;
    this.table.getMetaDataTemplateAttrList();
  }

  //搜索
  search() {
    template_attribute.retrieval.queryCriteria = this.searchData;
    template_attribute.retrieval.status = this.status;
    this.table.getMetaDataTemplateAttrList();
  }
  //响应搜索
  changesearch() {
      this.search();
  }

}
